#include "stm32f4xx.h"
#include "led.h"
#include "delay.h"
#include "key.h"
#include "exti.h"
#include "tim.h"
#include <math.h>

//占空比
float duty_cycle = 0.0f;
uint32_t time = 0;

int main()
{
    led_init();
    key_init();
    EXTI_config();
    TIM6_Init();
    GPIO_SetBits(LED_GROUP, LED1_PIN | LED2_PIN | LED3_PIN | LED4_PIN);

    while (1)
    {
        // led_blink();
        // key_led();
        // key_input_password();
        // key_control();
        // key_change_speed();
        // led_change_speed_water(led_speed_mode, led_water_mode, led_manual_light_num);
        time++;
        duty_cycle = sin(time / 5.0f) / 2.0f + 0.5f;
        GPIO_ResetBits(LED_GROUP, LED4_PIN);
        delay_ms((20 * duty_cycle));
        GPIO_SetBits(LED_GROUP, LED4_PIN);
        delay_ms((20 * (1 - duty_cycle)));
    }
}
